# @File: run.py
#-*- coding: utf-8 -*-
# __author:"super"
# @time:2025/7/21 14:50
import argparse
import textwrap

from get_define.handlers import handle_gen_models

if __name__ == "__main__":
    ap = argparse.ArgumentParser(
        formatter_class=argparse.RawDescriptionHelpFormatter,
        description=textwrap.dedent("""
            极简版 OpenAPI → attrs 模型生成器
            例子：
              python run.py -s swagger.json -o apis
        """)
    )
    # ,default='http://127.0.0.1:9999/api/aomaker-openapi.json'
    ap.add_argument("-s", "--spec", required=False, help="OpenAPI 规范文件路径（JSON/YAML/URL）")
    ap.add_argument("-o", "--output", help="输出目录")  # , default="apis"
    ap.add_argument("-c", "--class-name-strategy", default="operation_id",
                    choices=["operation_id", "summary", "tags"],
                    help="类名生成策略")
    ap.add_argument("-cs", "--custom-strategy", default=None, help="自定义命名策略模块路径")
    ap.add_argument("-B", "--base-api-class", default="get_define.api_object.BaseAPIObject",
                    help="基类完整路径（module.ClassName格式）")
    ap.add_argument("-A", "--base-api-class-alias", default=None, help="基类在生成代码中的别名")

    args = ap.parse_args()

    handle_gen_models(
        spec=args.spec,
        output=args.output,
        class_name_strategy=args.class_name_strategy,
        custom_strategy=args.custom_strategy,
        base_api_class=args.base_api_class,
        base_api_class_alias=args.base_api_class_alias
    )
